import java.io.*;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86136
 * Date: 2025-04-29
 * Time: 20:12
 */
public class Demo9 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入源文件路径：");
        String srcPath = scanner.next();
        System.out.println("请输入目标文件路径：");
        String destPath = scanner.next();
        File file = new File(srcPath);
        if(!file.getParentFile().isDirectory()) {
            System.out.println("源文件所在目录不存在");
        }
        try(InputStream inputStream = new FileInputStream(srcPath);
            OutputStream outputStream = new FileOutputStream(destPath)) {
            while(true) {
                byte[] data = new byte[1024];
                int n = inputStream.read();
                if (n == -1) {
                    break;
                }
                outputStream.write(data,0,n);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
